<?php
/**
 * Created by PhpStorm.
 * User: root
 * Date: 2017/8/1
 * Time: 14:27
 */

namespace app\api\controller\v1;

use app\api\validate\IDMustBePostiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;
use think\Exception;

class Banner
{
    /**
     * 获取指定id的banner信息
     * @url /banner/:id
     * @http GET
     * @id banner的id号
     */
    public function getBanner($id){
        //独立验证
        //验证器

        (new IDMustBePostiveInt())->goCheck();

            $banner = BannerModel::getBannerByID($id);
            if(!$banner){
                throw new Exception('內部錯誤');
            }
        return $banner;
    }
}